# -*- coding: utf-8 -*-
import requests
from bs4 import BeautifulSoup
# from food.models import Food, Page,Market


payload = {'id':'656'}
r = requests.get("http://www.tcprice.gov.cn/news1.asp", params=payload)
r.encoding = 'gbk'
# print r.text
soup = BeautifulSoup(r.text,'html5lib')
tbody = soup.find('td',{'class','ask3_infolist'}).find('tbody')
rows = tbody.find_all('tr')

data = []
i = 0
type = len(rows)
print type

# 市场 一共13个
# markets = rows[2].find_all('p')
# num = len(markets)
# print num
# j = 0
# for m in markets:
#     name = m.get_text()
#     print name
#     if j < num-1:
#         market_model = Market.objects.create_market(market_name=name)
#     j += 1


# 副食品种类 一共121种
for row in rows:
    cols = row.find_all('td')
    food = "".join(cols[0].text.strip().split())

    if 2 < i < type-1:
        print i
        print food
        #food_model = Food.objects.create_food(food_name=food)

    i += 1




